<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>LibCDS: /home/zsshen/Desktop/git-hub-code/C-Common-Data-Structures/include/container/priority_queue.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">LibCDS
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('priority__queue_8h.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">priority_queue.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>The priority queue implemented with binary heap.  
<a href="#details">More...</a></p>

<p><a href="priority__queue_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structPriorityQueue.html">PriorityQueue</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">The implementation for priority queue.  <a href="structPriorityQueue.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a53f2138b48d673da264d18fd51402c42"><td class="memItemLeft" align="right" valign="top">typedef struct _PriorityQueueData&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#a53f2138b48d673da264d18fd51402c42">PriorityQueueData</a></td></tr>
<tr class="memdesc:a53f2138b48d673da264d18fd51402c42"><td class="mdescLeft">&#160;</td><td class="mdescRight">PriorityQueueData is the data type for the container private information.  <a href="#a53f2138b48d673da264d18fd51402c42">More...</a><br/></td></tr>
<tr class="separator:a53f2138b48d673da264d18fd51402c42"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a729ca254ed0e2193b43719d62f5f2f56"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#a729ca254ed0e2193b43719d62f5f2f56">PriorityQueueInit</a> (<a class="el" href="structPriorityQueue.html">PriorityQueue</a> **ppObj)</td></tr>
<tr class="memdesc:a729ca254ed0e2193b43719d62f5f2f56"><td class="mdescLeft">&#160;</td><td class="mdescRight">The constructor for <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a>.  <a href="#a729ca254ed0e2193b43719d62f5f2f56">More...</a><br/></td></tr>
<tr class="separator:a729ca254ed0e2193b43719d62f5f2f56"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0adc505b578c221769f018813228bd32"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#a0adc505b578c221769f018813228bd32">PriorityQueueDeinit</a> (<a class="el" href="structPriorityQueue.html">PriorityQueue</a> **ppObj)</td></tr>
<tr class="memdesc:a0adc505b578c221769f018813228bd32"><td class="mdescLeft">&#160;</td><td class="mdescRight">The destructor for <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a>.  <a href="#a0adc505b578c221769f018813228bd32">More...</a><br/></td></tr>
<tr class="separator:a0adc505b578c221769f018813228bd32"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7aefd19c4559cdd822745d839684b494"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#a7aefd19c4559cdd822745d839684b494">PriorityQueuePush</a> (<a class="el" href="structPriorityQueue.html">PriorityQueue</a> *self, Item item)</td></tr>
<tr class="memdesc:a7aefd19c4559cdd822745d839684b494"><td class="mdescLeft">&#160;</td><td class="mdescRight">Push an item onto the queue.  <a href="#a7aefd19c4559cdd822745d839684b494">More...</a><br/></td></tr>
<tr class="separator:a7aefd19c4559cdd822745d839684b494"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2f17645f81207b3732fac992b622bcc8"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#a2f17645f81207b3732fac992b622bcc8">PriorityQueuePop</a> (<a class="el" href="structPriorityQueue.html">PriorityQueue</a> *self)</td></tr>
<tr class="memdesc:a2f17645f81207b3732fac992b622bcc8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete item from top of the queue.  <a href="#a2f17645f81207b3732fac992b622bcc8">More...</a><br/></td></tr>
<tr class="separator:a2f17645f81207b3732fac992b622bcc8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afc37a32ca097ba94e6a185cb9c64f85a"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#afc37a32ca097ba94e6a185cb9c64f85a">PriorityQueueTop</a> (<a class="el" href="structPriorityQueue.html">PriorityQueue</a> *self, Item *pItem)</td></tr>
<tr class="memdesc:afc37a32ca097ba94e6a185cb9c64f85a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Retrieve item from top of the queue.  <a href="#afc37a32ca097ba94e6a185cb9c64f85a">More...</a><br/></td></tr>
<tr class="separator:afc37a32ca097ba94e6a185cb9c64f85a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae02471464c82b3815f957ead9456b410"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#ae02471464c82b3815f957ead9456b410">PriorityQueueSize</a> (<a class="el" href="structPriorityQueue.html">PriorityQueue</a> *self)</td></tr>
<tr class="memdesc:ae02471464c82b3815f957ead9456b410"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the number of stored items.  <a href="#ae02471464c82b3815f957ead9456b410">More...</a><br/></td></tr>
<tr class="separator:ae02471464c82b3815f957ead9456b410"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6661f06cfaf73e1a6249deafd4087bd6"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#a6661f06cfaf73e1a6249deafd4087bd6">PriorityQueueSetCompare</a> (<a class="el" href="structPriorityQueue.html">PriorityQueue</a> *self, int32_t(*pFunc)(Item, Item))</td></tr>
<tr class="memdesc:a6661f06cfaf73e1a6249deafd4087bd6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the custom item comparison method.  <a href="#a6661f06cfaf73e1a6249deafd4087bd6">More...</a><br/></td></tr>
<tr class="separator:a6661f06cfaf73e1a6249deafd4087bd6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeef557efdaca187f8ed58cbd3e01703a"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="priority__queue_8h.html#aeef557efdaca187f8ed58cbd3e01703a">PriorityQueueSetDestroy</a> (<a class="el" href="structPriorityQueue.html">PriorityQueue</a> *self, void(*pFunc)(Item))</td></tr>
<tr class="memdesc:aeef557efdaca187f8ed58cbd3e01703a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the custom item resource clean method.  <a href="#aeef557efdaca187f8ed58cbd3e01703a">More...</a><br/></td></tr>
<tr class="separator:aeef557efdaca187f8ed58cbd3e01703a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The priority queue implemented with binary heap. </p>

<p>Definition in file <a class="el" href="priority__queue_8h_source.html">priority_queue.h</a>.</p>
</div><h2 class="groupheader">Typedef Documentation</h2>
<a class="anchor" id="a53f2138b48d673da264d18fd51402c42"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct _PriorityQueueData <a class="el" href="priority__queue_8h.html#a53f2138b48d673da264d18fd51402c42">PriorityQueueData</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>PriorityQueueData is the data type for the container private information. </p>

<p>Definition at line <a class="el" href="priority__queue_8h_source.html#l00011">11</a> of file <a class="el" href="priority__queue_8h_source.html">priority_queue.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a729ca254ed0e2193b43719d62f5f2f56"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t PriorityQueueInit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPriorityQueue.html">PriorityQueue</a> **&#160;</td>
          <td class="paramname"><em>ppObj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The constructor for <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ppObj</td><td>The double pointer to the to be constructed queue</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOMEM</td><td>Insufficient memory for queue construction </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a0adc505b578c221769f018813228bd32"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PriorityQueueDeinit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPriorityQueue.html">PriorityQueue</a> **&#160;</td>
          <td class="paramname"><em>ppObj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The destructor for <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a>. </p>
<p>If the custom resource clean method is set, it also runs the clean method for all the items.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ppObj</td><td>The double pointer to the to be destructed queue </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a7aefd19c4559cdd822745d839684b494"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t PriorityQueuePush </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPriorityQueue.html">PriorityQueue</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item&#160;</td>
          <td class="paramname"><em>item</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Push an item onto the queue. </p>
<p>This function pushes an item onto the queue with the corresponding queue size extension.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a> structure </td></tr>
    <tr><td class="paramname">item</td><td>The designated item</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_NOMEM</td><td>Insufficient memory for queue extension </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a2f17645f81207b3732fac992b622bcc8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t PriorityQueuePop </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPriorityQueue.html">PriorityQueue</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delete item from top of the queue. </p>
<p>This function deletes item from top of the queue. If the custom resource clean method is set, it also runs the clean method for the deleted item.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a> structure</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Empty queue </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="afc37a32ca097ba94e6a185cb9c64f85a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t PriorityQueueTop </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPriorityQueue.html">PriorityQueue</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item *&#160;</td>
          <td class="paramname"><em>pItem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Retrieve item from top of the queue. </p>
<p>This function retrieves item from top of the queue. If the queue is not empty, the item is returned by the second parameter. Otherwise, the error code is returned and the second parameter is updated with NULL.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a> structure </td></tr>
    <tr><td class="paramname">pItem</td><td>The pointer to the returned item</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Empty queue </td></tr>
    <tr><td class="paramname">ERR_GET</td><td>Invalid parameter to store returned item </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ae02471464c82b3815f957ead9456b410"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t PriorityQueueSize </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPriorityQueue.html">PriorityQueue</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Return the number of stored items. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a> structure</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of items </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a6661f06cfaf73e1a6249deafd4087bd6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t PriorityQueueSetCompare </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPriorityQueue.html">PriorityQueue</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t(*)(Item, Item)&#160;</td>
          <td class="paramname"><em>pFunc</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set the custom item comparison method. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a> structure </td></tr>
    <tr><td class="paramname">pFunc</td><td>The function pointer to the custom method</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aeef557efdaca187f8ed58cbd3e01703a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t PriorityQueueSetDestroy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPriorityQueue.html">PriorityQueue</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void(*)(Item)&#160;</td>
          <td class="paramname"><em>pFunc</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set the custom item resource clean method. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structPriorityQueue.html" title="The implementation for priority queue. ">PriorityQueue</a> structure </td></tr>
    <tr><td class="paramname">pFunc</td><td>The function pointer to the custom method</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_e0f5f6345e438c73b9ae78ec2940718c.html">container</a></li><li class="navelem"><a class="el" href="priority__queue_8h.html">priority_queue.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
